package com.wanglibao.woodtrade.woodtrade.model;

import android.text.TextUtils;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

/**
 * Created by lugg on 2016/5/24.
 */
@DatabaseTable
public class ShopOrder {

    /**
     * user_name : 18518011371
     * title : 紫檀木类
     * goods_number : 5
     * unit : 2
     * pay_time : 1499788800
     */
    @DatabaseField(generatedId = true)
    public int id;
    @DatabaseField
    public String user_name;
    @DatabaseField
    public String title;
    @DatabaseField
    public String goods_number;
    @DatabaseField
    public String unit;
    @DatabaseField
    public long pay_time;

    public static String initTitle(ShopOrder shopOrder){
        StringBuffer title = new StringBuffer("用户");
        int length = shopOrder.user_name.length();
        if (!TextUtils.isEmpty(shopOrder.user_name) && length > 4){
            title.append(shopOrder.user_name.substring(0,3)+"****"+shopOrder.user_name.substring(length - 4,length)+"购买了");
        }
        title.append(shopOrder.goods_number+shopOrder.unit+shopOrder.title);

        return title.toString();
    }

}
